import assert from "assert";
import {
  isPlainObject,
  noop,
  hasOwn,
  hyphenate,
  getTypeIndex,
} from "../prop-validate/helper.mjs";

describe("isPlainObject", function () {
  it("isPlainObject测试一个数据为纯对象", function () {
    assert.equal(isPlainObject({}), true);
  });
});

describe("noop", function () {
  it("noop是一个空函数", function () {
    assert.equal(noop(), undefined);
  });
});

describe("hasOwn", function () {
  it("hasOwn校验对象是否有某个属性", function () {
    const obj = { a: 1 };
    assert.equal(hasOwn(obj, "a"), true);
  });
});

describe("hyphenate", function () {
  it("hyphenate将fontSize变为font-size", function () {
    assert.equal(hyphenate("fontSize"), "font-size");
  });
});

describe('getTypeIndex', function () {
  it("Boolean在Boolean中为0", function () {
    assert.equal(getTypeIndex(Boolean, Boolean), 0);
  })

  it("Boolean在[String, Boolean]中为1", function () {
    assert.equal(getTypeIndex(Boolean, [String, Boolean]), 1)
  })

  it("Boolean在String中为-1", function () {
    assert.equal(getTypeIndex(Boolean, String), -1);
  })
  it("Boolean在[String, Number]中为-1", function() {
    assert.equal(getTypeIndex(Boolean, [String, Number]), -1);
  })
})
